<?php
class Front_ProductController extends FrontController implements IController{
	/**
	 * Product_Model
	 * @var Front_Product_Model
	 */
	protected $_model;
	public function detailsAction(){
		$id = $this->getContext()->request('productid',0);
		$details = $this->_model->getForViewDetails($id);
		if(isset($details) && isset($details[Product::NAME]))
			$this->view()->setViewTitle($details[Product::NAME] .' - ' . $details[Product::CATNAME]);
		$this->view()->productDetails = $details; 
		$this->view()->relatedCats = $this->_model->getRelateCatById($this->getContext(), $id);
		$this->view()->relatedTypes = $this->_model->getRelateTypeById($this->getContext(), $id);
	}
	public function catAction(){
		$id = $this->getContext()->request('catid',0);
		$list = $this->_model->getAllForCatView($this->getContext(), $id);
		$title = "";
		if(count($list)>0){
			$item = $list[0];
			$title = $item[Product::CATNAME];
		}else{
			$title = $this->_model->getProductCatName($id); 
		}
		$this->view()->setViewTitle($title);
		$this->view()->title = $title;
		$this->view()->list = $list; 
	}
}